package kr.hkit.powerjava.chapter10;

import java.util.Random;

class Histogram{
	private int[] arrNum = new int[10];
	private int[] arrHisto = new int[10];
	private Random rnd = new Random();
	
	public void setInputNum(){
		System.out.println("10개의 정수를 입력하세요.");
		for(int i = 0; i < 10; i++){
			arrNum[i] = rnd.nextInt(100)+1;
		}
		setHistogram();
	}
	
	public void setHistogram(){
		int num;
		int count = 0;
		
		for(int i = 0; i < arrNum.length; i++){
			num = arrNum[i];
			arrHisto[num/10]++;
		}
		
		for(int j = 0; j < arrNum.length; j++){
			System.out.print(arrNum[j] + "\t");
		}
		System.out.println();
		setStar();
	}
	
	public void setStar(){
		int j = 1;
		int k = 10;
		for(int i = 0; i < arrHisto.length; i++){
			System.out.print(j + "~" + k + ":" + arrHisto[i] + "개"); j += 10; k += 10;
			for(int z = 0; z < arrHisto[i]; z++){
				System.out.print("*");
			}
			System.out.println();
		}
	}
}

public class StarCheck {
	public static void main(String[] args) {
		Histogram h1 = new Histogram();
		h1.setInputNum();
	}
}
